import Vue from 'vue'
import debuger from './debuger.vue'

const DebugerConstructor = Vue.extend(debuger)

const removeDom = (target) => {
  target.parentNode.removeChild(target)
}

DebugerConstructor.prototype.close = function () {
  this.visible = false
  removeDom(this.$el)
}

const debugerDiv = (options) => {
  const instance = new DebugerConstructor({
    el: document.createElement('div'),
    data: options
  })

  document.body.appendChild(instance.$el)
  // Vue.nextTick(() => {
  //   instance.timer = setTimeout(() => {
  //     instance.close()
  //   }, 3000)
  // })

  return instance
}

export default debugerDiv
